@@ -31,12 +31,14 @@ class AgentsController < ApplicationController |
||
| 31 | 31 |
def received_reward |
| 32 | 32 |
user_reward = UserReward.find(params[:id]) |
| 33 | 33 |
user_reward.update(received: true, date_received: Time.now) |
| 34 |
+ @analytics.track('Reward received')
|
|
| 34 | 35 |
redirect_to(user_rewards_path(view: 'received'), notice: (t 'reward.marked_as_received')) |
| 35 | 36 |
end |
| 36 | 37 |
|
| 37 | 38 |
def not_received_reward |
| 38 | 39 |
user_reward = UserReward.find(params[:id]) |
| 39 | 40 |
user_reward.update(received: false, date_received: Time.now) |
| 41 |
+ @analytics.track('Reward not received')
|
|
| 40 | 42 |
redirect_to(user_rewards_path(view: 'not_received'), notice: (t 'reward.marked_as_not_received')) |
| 41 | 43 |
end |
| 42 | 44 |
|
@@ -9,6 +9,7 @@ class MissionEditor::DetailsController < ApplicationController |
||
| 9 | 9 |
|
| 10 | 10 |
def launch_mission |
| 11 | 11 |
if @mission.launch |
| 12 |
+ @analytics.track('Mission launched')
|
|
| 12 | 13 |
redirect_to mission_control_path(@mission), notice: (t 'mission_editor.mission_launched') |
| 13 | 14 |
else |
| 14 | 15 |
redirect_to mission_path(@mission), alert: (t 'mission_editor.launch_error') |
@@ -9,6 +9,7 @@ class MissionsController < ApplicationController |
||
| 9 | 9 |
@open_missions.delete_if { |m| m == @featured_missions }
|
| 10 | 10 |
@finished_missions = Mission.where("status = ? OR status = ?", 3, 4)
|
| 11 | 11 |
@finished_missions.delete_if { |m| m == @featured_missions }
|
| 12 |
+ @analytics.track('Mission list view')
|
|
| 12 | 13 |
end |
| 13 | 14 |
|
| 14 | 15 |
def mission_control |
@@ -47,6 +48,7 @@ class MissionsController < ApplicationController |
||
| 47 | 48 |
def create |
| 48 | 49 |
@mission = Mission.new(mission_params) |
| 49 | 50 |
@mission.owner = current_user |
| 51 |
+ @analytics.track('Mission created')
|
|
| 50 | 52 |
respond_to do |format| |
| 51 | 53 |
if @mission.save |
| 52 | 54 |
format.html { redirect_to rewards_path(@mission), notice: 'Mission was successfully created.' }
|
@@ -90,6 +92,7 @@ class MissionsController < ApplicationController |
||
| 90 | 92 |
candidate = MissionCandidate.create!(user: current_user, mission_agent: agent, status: 1, mode: 'take_agent_role') |
| 91 | 93 |
agent.user = current_user |
| 92 | 94 |
if agent.save |
| 95 |
+ @analytics.track('Agent role selected')
|
|
| 93 | 96 |
redirect_to mission_agent_details_path(mission, agent), notice: (t 'mission.take_agent_profile_confirmation') |
| 94 | 97 |
else |
| 95 | 98 |
redirect_to mission_agent_details_path(mission, agent), alert: (t 'mission.take_agent_profile_error') |
@@ -106,6 +109,7 @@ class MissionsController < ApplicationController |
||
| 106 | 109 |
submission = step.create_submission(step_submission_params, params[:step_submission][:submission_contents_attributes].values) |
| 107 | 110 |
respond_to do |format| |
| 108 | 111 |
if submission.save |
| 112 |
+ @analytics.track('Step submitted')
|
|
| 109 | 113 |
format.html { redirect_to mission_agent_details_path(mission, agent), notice: (t 'mission.step_submission_confirmation') }
|
| 110 | 114 |
format.json { head :no_content }
|
| 111 | 115 |
else |
@@ -126,6 +130,7 @@ class MissionsController < ApplicationController |
||
| 126 | 130 |
submission.date_validated = Time.now |
| 127 | 131 |
submission.save |
| 128 | 132 |
submission.agent_step.update(completed: true) |
| 133 |
+ @analytics.track('Step accepted')
|
|
| 129 | 134 |
Resque.enqueue(SendStepNotification, submission.agent_step.id, 'validated') |
| 130 | 135 |
#MissionMailer.step_validation_notification(submission.agent_step).deliver |
| 131 | 136 |
mission.check_for_completion |
@@ -143,6 +148,7 @@ class MissionsController < ApplicationController |
||
| 143 | 148 |
submission.validated_by = current_user |
| 144 | 149 |
submission.date_validated = Time.now |
| 145 | 150 |
submission.save |
| 151 |
+ @analytics.track('Step denied')
|
|
| 146 | 152 |
Resque.enqueue(SendStepNotification, submission.agent_step.id, 'denied') |
| 147 | 153 |
redirect_to mission_control_path(mission) |
| 148 | 154 |
end |
@@ -18,6 +18,7 @@ class Users::RegistrationsController < Devise::RegistrationsController |
||
| 18 | 18 |
|
| 19 | 19 |
if successfully_updated |
| 20 | 20 |
set_flash_message :notice, :updated |
| 21 |
+ @analytics.track('Profile updated')
|
|
| 21 | 22 |
# Sign in the user bypassing validation in case his password changed |
| 22 | 23 |
sign_in @user, :bypass => true |
| 23 | 24 |
redirect_to after_update_path_for(@user) |
@@ -137,6 +137,8 @@ class Mission < ActiveRecord::Base |
||
| 137 | 137 |
end |
| 138 | 138 |
|
| 139 | 139 |
def completed |
| 140 |
+ analytics = Analytics.new |
|
| 141 |
+ analytics.track('Mission completed')
|
|
| 140 | 142 |
self.update(status: 3) |
| 141 | 143 |
self.rewards.each do |reward| |
| 142 | 144 |
reward.distribute |
@@ -144,6 +146,8 @@ class Mission < ActiveRecord::Base |
||
| 144 | 146 |
end |
| 145 | 147 |
|
| 146 | 148 |
def failed |
| 149 |
+ analytics = Analytics.new |
|
| 150 |
+ analytics.track('Mission failed')
|
|
| 147 | 151 |
self.update(status: 4) |
| 148 | 152 |
end |
| 149 | 153 |
|